<?php


namespace app\api\controller;

use think\DB;
class Xw
{
  public function Xw(){

      $id = input('id');
      if(!$id){
          return 0;
      }//判断有无参数
      //进行数据库查询nav
      $data = Db::name('article ba')
          ->join('attachment b', 'ba.thumb=b.id')
          ->field('ba.id,ba.title,ba.content')
          ->where('ba.id',$id)
          ->select();
      foreach ($data as $key => &$v) {
        //  $v['filepath'] = 'http://' . $_SERVER['HTTP_HOST'] . $v['filepath'];
          $v['content']  = str_replace("/ueditor", 'http://' . $_SERVER['SERVER_NAME'] . "/ueditor", $v['content']);
      }
      if ($data) {
          return json(['code' => 200, 'msg' => "成功", 'data' => $data]);
      } else {
          return json(['code' => 0, 'msg' => "失败", 'data' => []]);
      }

  }
}